| Philipp Hancke | b7014f7 | 2017-02-27 13:24:20 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 5 | <title>RTCPeerConnection setRemoteDescription tests</title> |
| 6 | </head> |
| 7 | <body> |
| 8 | <!-- These files are in place when executing on W3C. --> |
| 9 | <script src="/resources/testharness.js"></script> |
| 10 | <script src="/resources/testharnessreport.js"></script> |
| 11 | <script type="text/javascript"> |
| Philipp Hancke | 86eb3cb | 2017-04-13 16:19:50 | [diff] [blame] | 12 | // tests that ontrack is called and parses the msid information from the SDP and creates |
| Philipp Hancke | 0e55032 | 2017-05-03 13:46:49 | [diff] [blame] | 13 | // the streams with matching identifiers. |
| Philipp Hancke | b7014f7 | 2017-02-27 13:24:20 | [diff] [blame] | 14 | async_test(function(test) { |
| 15 | const sdp = 'v=0\r\n' + |
| 16 | 'o=- 166855176514521964 2 IN IP4 127.0.0.1\r\n' + |
| 17 | 's=-\r\n' + |
| 18 | 't=0 0\r\n' + |
| 19 | 'a=msid-semantic:WMS *\r\n' + |
| 20 | 'm=audio 9 UDP/TLS/RTP/SAVPF 111\r\n' + |
| 21 | 'c=IN IP4 0.0.0.0\r\n' + |
| 22 | 'a=rtcp:9 IN IP4 0.0.0.0\r\n' + |
| 23 | 'a=ice-ufrag:someufrag\r\n' + |
| 24 | 'a=ice-pwd:somelongpwdwithenoughrandomness\r\n' + |
| 25 | 'a=fingerprint:sha-256 8C:71:B3:8D:A5:38:FD:8F:A4:2E:A2:65:6C:86:52:BC:E0:6E:94:F2:9F:7C:4D:B5:DF:AF:AA:6F:44:90:8D:F4\r\n' + |
| 26 | 'a=setup:actpass\r\n' + |
| 27 | 'a=rtcp-mux\r\n' + |
| 28 | 'a=mid:mid1\r\n' + |
| 29 | 'a=sendonly\r\n' + |
| 30 | 'a=rtpmap:111 opus/48000/2\r\n' + |
| 31 | 'a=msid:stream1 track1\r\n' + |
| 32 | 'a=ssrc:1001 cname:some\r\n'; |
| 33 | |
| 34 | var pc = new RTCPeerConnection(null); |
| 35 | |
| Philipp Hancke | 86eb3cb | 2017-04-13 16:19:50 | [diff] [blame] | 36 | pc.ontrack = test.step_func(function(event) { |
| Philipp Hancke | 86eb3cb | 2017-04-13 16:19:50 | [diff] [blame] | 37 | assert_equals(event.streams.length, 1, 'the track belongs to one MediaStream'); |
| 38 | assert_equals(event.streams[0].id, 'stream1', 'the stream name is parsed from the MSID line'); |
| Philipp Hancke | b7014f7 | 2017-02-27 13:24:20 | [diff] [blame] | 39 | test.done(); |
| 40 | }); |
| 41 | |
| 42 | pc.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp})) |
| 43 | .catch(test.step_func(function(e) { |
| 44 | assert_unreached('Error ' + e.name + ': ' + e.message); |
| 45 | })); |
| Philipp Hancke | 0e55032 | 2017-05-03 13:46:49 | [diff] [blame] | 46 | }, 'Triggers ontrack when called with a remote description and the MSID of the stream is is parsed.'); |
| Soares Chen | a61973d | 2017-05-02 04:28:48 | [diff] [blame] | 47 | |
| 48 | promise_test(() => { |
| Soares Chen | 3be0b10 | 2017-05-02 04:37:58 | [diff] [blame^] | 49 | const pc = new RTCPeerConnection(); |
| Soares Chen | a61973d | 2017-05-02 04:28:48 | [diff] [blame] | 50 | return pc.setRemoteDescription( |
| 51 | {'type': 'offer', 'sdp': 'bogus'}) |
| 52 | .then(() => { |
| 53 | assert_unreached('Bogus SDP should not be accepted'); |
| 54 | }) |
| 55 | .catch(e => { |
| 56 | assert_equals(e.name, 'InvalidAccessError'); |
| 57 | }); |
| 58 | }, 'Bogus SDP'); |
| 59 | |
| 60 | promise_test(() => { |
| Soares Chen | 3be0b10 | 2017-05-02 04:37:58 | [diff] [blame^] | 61 | const pc = new RTCPeerConnection(); |
| Soares Chen | a61973d | 2017-05-02 04:28:48 | [diff] [blame] | 62 | return pc.setRemoteDescription( |
| 63 | {'type': 'bogus', 'sdp': 'bogus'}) |
| 64 | .then(() => { |
| 65 | assert_unreached('Bogus operation types should not be accepted'); |
| 66 | }) |
| 67 | .catch(e => { |
| 68 | assert_equals(e.name, 'TypeError'); |
| 69 | }); |
| 70 | }, 'Bogus Operation'); |
| 71 | |
| 72 | promise_test(() => { |
| Soares Chen | 3be0b10 | 2017-05-02 04:37:58 | [diff] [blame^] | 73 | const pc = new RTCPeerConnection(); |
| Soares Chen | a61973d | 2017-05-02 04:28:48 | [diff] [blame] | 74 | return pc.setRemoteDescription( |
| 75 | {'type': 'answer', 'sdp': 'bogus'}) |
| 76 | .then(() => { |
| 77 | assert_unreached('Answer in "new" state should not be accepted'); |
| 78 | }) |
| 79 | .catch(e => { |
| 80 | assert_equals(e.name, 'InvalidStateError'); |
| 81 | }); |
| 82 | }, 'Bogus operation for state'); |
| Philipp Hancke | b7014f7 | 2017-02-27 13:24:20 | [diff] [blame] | 83 | </script> |
| 84 | |
| 85 | </body> |
| 86 | </html> |